/**
 * print.h
 *
 *  Created on: 2021.05.22
 *      Author: wangbing
 *      Email : mz8023yt@163.com
 */

#ifndef _MAZ_ASSERTS_H_
#define _MAZ_ASSERTS_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "maz/print.h"

#define assert_rtvm(condition, ret, fmt, msg...)    \
    if (condition)                                  \
    {                                               \
        dlog(DERR, fmt, ##msg);                     \
        return ret;                                 \
    }

#define assert_retm(condition, fmt, msg...)         \
    if (condition)                                  \
    {                                               \
        dlog(DERR, fmt, ##msg);                     \
        return;                                     \
    }

#define assert_ctnm(condition, fmt, msg...)         \
    if (condition)                                  \
    {                                               \
        dlog(DERR, fmt, ##msg);                     \
        continue;                                   \
    }

#define assert_brkm(condition, fmt, msg...)         \
    if (condition)                                  \
    {                                               \
        dlog(DERR, fmt, ##msg);                     \
        break;                                      \
    }

#define assert_rtv(condition, ret)                  \
    if (condition)                                  \
    {                                               \
        return ret;                                 \
    }

#define assert_ret(condition)                       \
    if (condition)                                  \
    {                                               \
        return;                                     \
    }

#define assert_ctn(condition)                       \
    if (condition)                                  \
    {                                               \
        continue;                                   \
    }

#define assert_brk(condition)                       \
    if (condition)                                  \
    {                                               \
        break;                                      \
    }

#ifdef __cplusplus
}
#endif

#endif /* _MAZ_ASSERTS_H_ */

